/**
 * @author 2404559603@qq.com
 * @date 2022-05-16 11AM
 * @description 应用的实例入口文件
 */
import Vue from 'vue'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

/** 业务入口 */
import App from './pages'

import router from './router'

import store from './store'

import Layout from './pages/common/Layout'
Vue.component('Layout', Layout)

/** 虚拟dom挂载到真实dom的一个实例 */

// 动态路由刷新变成空白问题解决
JSON.parse(sessionStorage.getItem('routes'))?.reduce((routes, it) => {
    if (!!it.path) {
        // 好像只能单个添加
        router.addRoute('a',{path: it.path.slice(1), component: () => import('@/pages' + it.path)})
        routes.push({path: it.path, component: () => import('@/pages' + it.path), meta:{address: it.name} })
    }
    return routes
}, [])

new Vue({
    router,
    store,
    render: ce => ce(App)
}).$mount('#root')
